<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>钩子3</title>
    <script src="../../js/vue3.js"></script>
    <style>
        #app {
            margin: 2rem auto;
            width: 30%;
        }
        
        p {
            font-size: 1.5rem;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div id="app">
       <p ref="vp">{{msg}}</p>
       <p><button @click="deletes">销毁</button></p>


    </div>
    <script>
        const v_app = Vue.createApp({
            data() {
                return {
                    msg:"文本",
                }
            },
            beforeUnmount(){
                console.log("before")
                console.log(this.$data.msg);
                console.log(this.$refs.vp);
                console.log(v_app);
               
            },
            unmounted(){
                console.log("after")
                console.log(this.$data.msg);
                console.log(this.$refs.vp);
                console.log(v_app);
               
            },
            methods:{
                deletes(){
                    v_app.unmount();
                }
            }
        });
        v_app.mount("#app");
    </script>
</body>

</html>